<template>
  <el-table :data="tableData" border style="width: 100%" size='mini' :height="height">
    <el-table-column prop="address" label="物业地址"></el-table-column>
    <el-table-column prop="cityEara" label="区域" width="100"></el-table-column>
    <el-table-column prop="customer" label="业主" width="90"></el-table-column>
    <el-table-column prop="phone" label="手机号" width="120"></el-table-column>
    <el-table-column prop="deliveryStatusName" label="交付状况" width="100"></el-table-column>
    <el-table-column prop="getHomeDate" label="收房日期" width="110" sortable></el-table-column>
    <el-table-column prop="serviceTime" label="验房时间段" width="120"></el-table-column>
    <el-table-column prop="adminName" label="服务管家" width="90"></el-table-column>
    <el-table-column prop="adminPhone" label="管家手机号" width="120"></el-table-column>
    <el-table-column prop="createTime" label="报告完成时间" width="140" sortable></el-table-column>
    <el-table-column prop="address" label="评价">
        <template slot-scope="scope">
            <span class="star" v-if="scope.row.score">{{scope.row.score}}星</span>
            <span>{{scope.row.comments}}</span>
        </template>
    </el-table-column>
    <el-table-column label="操作" width="100">
      <template slot-scope="scope">
        <el-button @click="seeReport(scope.row)" type="text" size="small">查看报告</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import { request } from "../../assets/request.js";
export default {
  data() {
    return {
      height: window.innerHeight - (window.innerWidth <1356? 347 :283),//计算表格高度
      tableData: [],//列表数据
      obj:{
        page:1,
        size:20
      },
    };
  },
  created(){
    this.selectList(this.obj)
    this.$root.$on('searchReport',(data)=>{
      if(data!='no'){
        this.obj=data
      }
      this.selectList(this.obj)
    })
  },
  methods:{
    seeReport(row){ //查看报告
      this.$root.$emit('seeReport',row)
    },
    selectList(obj){ //查询列表数据
      let url = "order/report";
      let that=this   //解决this指向问题
      request.ajaxGet({
        url,
        that,
        params:obj,
        fn(res){
          console.log(res.list)
          let data=res.list
          for(let i in data){
            data[i].deliveryStatusName=data[i].deliveryStatus==1?'精装':'毛坯'
          }
          that.$root.$emit("reportList",res.total)
          that.tableData=res.list
        }
      })
    }
  }
};
</script>
<style lang="less" scoped>
.star{
    background: #ff9900;
    color: #fff;
    padding: 3px 5px;
    border-radius: 2px;
    margin-right: 5px;
}
</style>

